class Solution {
    public:
        int minimumOperations(vector<int>& nums) {
            map<int,int> window;
            int n = nums.size();
            int end = -1;
            for(int i = 0;i < n;i++){
                if(window.count(nums[i])){
                    end = max(window[nums[i]],end);
                }
                window[nums[i]] = i;
            }
            if(end == -1)
                return 0;
            return (end)/3 + 1;
        }
    };